package ch06.symtab.monolithic;

import org.antlr.runtime.*;

import java.io.IOException;

public class Test {
    public static void main(String[] args) throws RecognitionException, IOException {
        CharStream input = null;
        if (args.length > 0) {
            input = new ANTLRFileStream((args[0]));
        } else {
            input = new ANTLRInputStream(System.in);
        }

        CymbolLexer lex = new CymbolLexer(input);                   // 创建词法解析器
        CommonTokenStream tokens = new CommonTokenStream(lex);
        CymbolParser p = new CymbolParser(tokens);                  // 创建语法解析器
        SymbolTable symtab = new SymbolTable();                     // 创建符号表
        p.compilationUnit(symtab);                                  // 调用符号表
        System.out.println("globals: " + symtab.symbols);
    }
}
